<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .mouse_move {
            display: inline-block;
            background: blue;
            width: 500px;
            height: 500px;
            margin: 20px;
        }

        span {
            color: white;
        }

        button {
            position: absolute;
            left: 400px;
            top: 400px;
        }
    </style>
    <script src="./throttle.js"></script>
</head>
<body>

<div class="mouse_move">
    <span>Throttle1</span>
</div>

<button>取消</button>

<div class="mouse_move">
    <span>Proxy</span>
</div>


<script >
    const TIME = 2000

    function handler() {
        console.log(1)
    }

    let throttledFunc = throttle(handler, TIME)
    let btn = document.querySelector("button")
    btn.onclick = throttledFunc.cancel

    let mousemoveElementList = document.querySelectorAll('.mouse_move')
    mousemoveElementList[0].addEventListener('mousemove', throttledFunc)
    mousemoveElementList[1].addEventListener('mousemove', proxy(handler, TIME))

</script>
</body>
</html>
